<?php

namespace app\admin\controller;

use think\Db;
use think\Request;
use app\admin\controller\Base;
use app\admin\model\SymbolCat as modelSymbolCat;

class SymbolCat extends base
{

    //
    public function index()
    {
        return $this->fetch();
    }
    //分类列表
    public function list(){

        $symbolcat=new modelSymbolCat;
        $symbolcat=$symbolcat->getlist();
        $this->assign('symbolcat',$symbolcat);
        return $this->fetch('list');
    }

    //分类添加
    public function add(Request $request){
        if($request->ispost()){
            $pid   = $request->param('pid','trim');
            $title = $request->param('title','trim');
            $status= $request->param('status','trim');
            $sort  = $request->param('sort','trim');
            $created_at=time();
            $data=['pid'=>$pid,'title'=>$title,'status'=>$status,'sort'=>$sort,'created_at'=>$created_at];
            $symbolcat=new modelSymbolCat;
            $res=$symbolcat->insertCat($data);
            if($res){
                $this->success('添加成功','admin/symbolcat/list');
            }else{
                $this->error('添加失败','admin/symbolcat/list');
            }
        }
        return $this->fetch('add');
    }
    //修改分类信息
    public function catedit($id){
        return 3333;exit;
    }




}
